package com.cty.A_GeneralDataStructures.A_Array.OrdArray;

import com.cty.A_GeneralDataStructures.A_Array.Array.Array;
import com.cty.F_common.DataItem;

/**
 * @Auther: cty
 * @Date: 2020/6/13 17:07
 * @Description: 测试有序数组
 * @version: 1.0
 */
public class OrdArrayApp {
    public static void main(String[] args) {
        OrdArray arr = new OrdArray(10);
        long searchKey;


        System.out.println("测试 insert()");
        arr.insert(new DataItem(99));
        arr.insert(new DataItem(88));
        arr.insert(new DataItem(77));
        arr.insert(new DataItem(66));
        arr.insert(new DataItem(55));
        arr.insert(new DataItem(44));
        arr.insert(new DataItem(33));
        arr.insert(new DataItem(22));
        arr.insert(new DataItem(11));
        arr.insert(new DataItem(0));

        int insertValue = 33;
        if(arr.insert(new DataItem(insertValue))){
            System.out.println("Insert " + insertValue);
        } else{
            System.out.println("Can't insert " + insertValue);
        }
        arr.displayArray();
        System.out.println("---------------------------------------------------------");


        System.out.println("测试 find()");
        searchKey = 66;
        if(arr.find(searchKey) != null){
            System.out.println("Found " + searchKey);
        }
        else{
            System.out.println("Can't find " + searchKey);
        }
        System.out.println("---------------------------------------------------------");


        System.out.println("测试 delete()");
        arr.delete(0);
        arr.delete(55);

        searchKey = 18;
        if(arr.delete(searchKey) != null)
            System.out.println("Deleted " + searchKey);
        else
            System.out.println("Can't delete " + searchKey);

        arr.displayArray();
        System.out.println("---------------------------------------------------------");

    }  // end main()
}  // end OrdArrayApp


/**
 * 测试 insert()
 * Can't insert 33
 * 0 11 22 33 44 55 66 77 88 99
 * ---------------------------------------------------------
 * 测试 find()
 * Found 66
 * ---------------------------------------------------------
 * 测试 delete()
 * Can't delete 18
 * 11 22 33 44 66 77 88 99
 * ---------------------------------------------------------
 */
